#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test Rust support: propagation of 'rust-format'.

cat <<\EOF > xg-rs-7.rs
  gettext ("Hello10");
  (gettext ("Hello11"));
  ((gettext ("Hello12")));
  gettext (gettext ("Hello13"));
  (gettext (gettext ("Hello14")));
  ((gettext (gettext ("Hello15"))));
  gettext ((gettext ("Hello16")));
  gettext (((gettext ("Hello17"))));
  gettext (foo(), gettext ("Hello18"));

  format (gettext ("Hello20"));
  format ((gettext ("Hello21")));
  format (((gettext ("Hello22"))));
  format (gettext (gettext ("Hello23")));
  format ((gettext (gettext ("Hello24"))));
  format (((gettext (gettext ("Hello25")))));
  format (gettext ((gettext ("Hello26"))));
  format (gettext (((gettext ("Hello27")))));
  format (gettext (foo(), gettext ("Hello28")));

  println! ("{}", gettext ("Hello30"));
  println! ("{}", (gettext ("Hello31")));
  println! ("{}", ((gettext ("Hello32"))));
  println! ("{}", gettext (gettext ("Hello33")));
  println! ("{}", (gettext (gettext ("Hello34"))));
  println! ("{}", ((gettext (gettext ("Hello35")))));
  println! ("{}", gettext ((gettext ("Hello36"))));
  println! ("{}", gettext (((gettext ("Hello37")))));
  println! ("{}", gettext (foo(), gettext ("Hello38")));

  formatx! (gettext ("Hello40"));
  formatx! ((gettext ("Hello41")));
  formatx! (((gettext ("Hello42"))));
  formatx! (gettext (gettext ("Hello43")));
  formatx! ((gettext (gettext ("Hello44"))));
  formatx! (((gettext (gettext ("Hello45")))));
  formatx! (gettext ((gettext ("Hello46"))));
  formatx! (gettext (((gettext ("Hello47")))));
  formatx! (gettext (foo(), gettext ("Hello48")));

  println! ("{}", formatx! (gettext ("Hello50")));
  println! ("{}", formatx! ((gettext ("Hello51"))));
  println! ("{}", formatx! (((gettext ("Hello52")))));
  println! ("{}", formatx! (gettext (gettext ("Hello53"))));
  println! ("{}", formatx! ((gettext (gettext ("Hello54")))));
  println! ("{}", formatx! (((gettext (gettext ("Hello55"))))));
  println! ("{}", formatx! (gettext ((gettext ("Hello56")))));
  println! ("{}", formatx! (gettext (((gettext ("Hello57"))))));
  println! ("{}", formatx! (gettext (foo(), gettext ("Hello58"))));
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} --omit-header --no-location --flag=format:1:rust-format -d xg-rs-7.tmp xg-rs-7.rs || Exit 1
LC_ALL=C tr -d '\r' < xg-rs-7.tmp.po > xg-rs-7.po || Exit 1

cat <<\EOF > xg-rs-7.ok
msgid "Hello10"
msgstr ""

msgid "Hello11"
msgstr ""

msgid "Hello12"
msgstr ""

msgid "Hello13"
msgstr ""

msgid "Hello14"
msgstr ""

msgid "Hello15"
msgstr ""

msgid "Hello16"
msgstr ""

msgid "Hello17"
msgstr ""

msgid "Hello18"
msgstr ""

#, rust-format
msgid "Hello20"
msgstr ""

#, rust-format
msgid "Hello21"
msgstr ""

#, rust-format
msgid "Hello22"
msgstr ""

#, rust-format
msgid "Hello23"
msgstr ""

#, rust-format
msgid "Hello24"
msgstr ""

#, rust-format
msgid "Hello25"
msgstr ""

#, rust-format
msgid "Hello26"
msgstr ""

#, rust-format
msgid "Hello27"
msgstr ""

msgid "Hello28"
msgstr ""

msgid "Hello30"
msgstr ""

msgid "Hello31"
msgstr ""

msgid "Hello32"
msgstr ""

msgid "Hello33"
msgstr ""

msgid "Hello34"
msgstr ""

msgid "Hello35"
msgstr ""

msgid "Hello36"
msgstr ""

msgid "Hello37"
msgstr ""

msgid "Hello38"
msgstr ""

#, rust-format
msgid "Hello40"
msgstr ""

#, rust-format
msgid "Hello41"
msgstr ""

#, rust-format
msgid "Hello42"
msgstr ""

#, rust-format
msgid "Hello43"
msgstr ""

#, rust-format
msgid "Hello44"
msgstr ""

#, rust-format
msgid "Hello45"
msgstr ""

#, rust-format
msgid "Hello46"
msgstr ""

#, rust-format
msgid "Hello47"
msgstr ""

msgid "Hello48"
msgstr ""

#, rust-format
msgid "Hello50"
msgstr ""

#, rust-format
msgid "Hello51"
msgstr ""

#, rust-format
msgid "Hello52"
msgstr ""

#, rust-format
msgid "Hello53"
msgstr ""

#, rust-format
msgid "Hello54"
msgstr ""

#, rust-format
msgid "Hello55"
msgstr ""

#, rust-format
msgid "Hello56"
msgstr ""

#, rust-format
msgid "Hello57"
msgstr ""

msgid "Hello58"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-rs-7.ok xg-rs-7.po || Exit 1

exit 0
